import taichi as ti

ti.init()

@ti.kernel
def copy(x:ti.template(), y:ti.template()):
    # 打包y的下标
    for I in ti.grouped(y):
        # 所有下标一起复制
        x[I]=y[I]

@ti.kernel
def array_op(x:ti.template(),y:ti.template()):
    # 两个for循环在2d情况下作用相同
    for I in ti.grouped(x):
        y[I]=I[0]+I[1]
    
    for i,j in x:
        y[i,j]=i+j

x = ti.field(dtype=ti.f32,shape=(10,10))
y = ti.field(dtype=ti.f32,shape=(10,10))

array_op(x,y)
copy(x,y)
print(x)
print(y)